<template>
  <div>
 
    <div class="container">

        <div class="item12">

            <div class="item1">
                <mymenu></mymenu>
            </div>

            <div class="item2">
                <p> 角色分组</p>
                  <van-checkbox-group v-model="checked" ref="checkboxGroup">
                   
               
                    <p v-for="i,j in rolelist" :key="j">{{i.name}}<van-checkbox :name="i.id"></van-checkbox></p>
             
                 </van-checkbox-group><br>
                 <van-button color="orange" @click="submit" size="small">用户分组</van-button>
                 
            </div>


        </div>

    </div>

  </div>
</template>

<script>
import { stringify } from 'qs'
import mymenu from '../components/menu.vue'
export default {

  data(){
    return{
        rolelist:[], //节点列表
        checked:[], //选择的节点
 
    }
  },
  components:{
    mymenu
  },
  methods:{
    submit(){
        // alert(stringify(this.checked))
    this.myaxios(this.baseURL+'role/','put',{checked:JSON.stringify(this.checked)}).then(resp=>{
      console.log('修改角色',resp)
      if(resp.errcode == 0){
        this.$toast.success(resp.msg)
      }else{
        this.$toast.fail(resp.msg)
      }
  }) 
        
    },
    // noaccess(){
    //     this.myaxios(this.baseURL+'access/','delete',{checked:JSON.stringify(this.checked)}).then(resp=>{
    //   console.log('删除权限',resp)
    //   if(resp.errcode == 0){
    //     this.$toast.success(resp.msg)
    //   }})
    // },
    //获取所有节点
    get_nodelist(){
        this.myaxios(this.baseURL+'role/','get').then(resp=>{
      console.log('获取角色列表',resp)
      if(resp.errcode == 0){
        this.rolelist = resp.data
            // 再去 携带cate 获取已有节点
            this.myaxios(this.baseURL+'role/','get',{cate:"user"}).then(resp=>{
            console.log('获取已有节点列表',resp)
            if(resp.errcode == 0){
                this.checked = resp.data
      }
  }) 
      }
  }) 
    },
      
  },
  mounted(){
    
  },
  created(){
   

    this.get_nodelist()
  }
    

}
</script>

<style>

</style>